home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / gnustuff / tos / 881 / src6.zoo / floor.c < prev    next >
Encoding:
Text File  |  1991-09-24  |  265 b   |  28 lines

  1. /*
  2.  * floor and ceil
  3.  *     from pete housels posting
  4.  */
  5.  
  6. double    modf(double, double *);
  7.  
  8. double
  9. floor(x)
  10. double x;
  11. {
  12.  double fract;
  13.  
  14.  fract = modf(x, &x);
  15.  
  16.  if(fract < 0.0)
  17.     return x - 1.0;
  18.  else
  19.     return x;
  20. }
  21.  
  22. double
  23. ceil(x)
  24. double x;
  25. {
  26.     return(-floor(-x));
  27. }
  28.